pp108 : Parallel Transactions

Parallel Transactions

This topic describes parallel transactions.


Users can initiate multiple transactions at the same time, but all cannot be committed at once. The queuing of transactions and persistence is internally handled by WS-AppServer. WS-AppServer provides certain methods that can be used to run more than one transaction at the same time. These transactions may be triggered at different times but they run simultaneously. This option is useful especially when there are dependent transactions in a process flow.
WS-AppServer contains two classes that are responsible for handling transactions. These are:

  • BusObjectManager class
  • BSF class

    Either of these can be used to manage a transaction. However, managing parallel transactions is supported by only BusObjectManager class.
    The following code sample describes how to start a transaction parallel to another transaction.
    // Config object wraps the Database Configuration information; if config is null then // the default information (from <Process_Platform_Installation_Directory>/bsf/bsfconfig.xml) is // used. For more details on bsfconfig.xml, see Using Embedded WS-AppServer|Embedding WS-AppServer Functionality in Applications|This topic describes the procedure to use WS-AppServer in embedded mode.. Config config = null; // Remove the comment from the below method call to start the default transaction, if it is not set to automatic in bsfconfig.xml file. // BSF.startTransaction(String transactionID); // // ..........write your application logic here ........ // String transactionOne = "1"; // arbitrary number BusObjectManager bom = new BusObjectManager(config, BSF.getXMLDocument()); // parallel transaction bom.startTransaction(transactionOne); // Started a parallel transaction with transactionId '1' // Associating a bus object with this transaction Customers oCustomer= new Customers(new BusObjectConfig(bom, 0, BusObjectConfig.NEW_OBJECT)); oCustomer.setCustomerID("JOHN"); oCustomer.insert(); // The record is not yet inserted in the database - waits for a commit. bom.commitTransaction(transactionOne, true); // Committed the transaction with transactionId = 1 String transactionTwo = "2"; // arbitrary number BusObjectManager bom2 = new BusObjectManager(config, BSF.getXMLDocument()); // parallel transaction bom2.startTransaction(transactionTwo); // Started a parallel transaction with transactionId '2' // Associating a bus object with this transaction Customers customer= new Customers(new BusObjectConfig(bom2, 0, BusObjectConfig.NEW_OBJECT)); customer.setCustomerID("JOHN"); customer.insert(); // The record is not yet inserted in the database - waits for a commit. bom2.commitTransaction(transactionTwo, true); // Committed the transaction with transactionId = 2 // // ..........write your application logic here ........ // // Remove the comment from the below method call to commit the default transaction, if it is not set to automatic in the bsfconfig.xml file. // BSF.commitTransaction(String transactionID);

    For more details on using these classes and methods, refer WS-AppServer SDK.

Related reference

Starting a Transaction
Retrying a Transaction

Related information

Managing Transactions Using WS-AppServer